import React, { Component } from 'react'
import { withRouter } from 'react-router-dom'

class Header extends Component {
  back = () => {
    this.props.history.goBack()
  }

  forward = () => {
    this.props.history.goForward()
  }

  go = () => {
    this.props.history.go(2)
  }
  render() {
    return (
      <div>
        <h2>我是头部标题</h2>
        {/* 手动回退、前进 */}
        <div>
          <button onClick={this.back}>回退</button>&nbsp;
          <button onClick={this.forward}>前进</button>&nbsp;
          <button onClick={this.go}>通用</button>
        </div>
      </div>
    )
  }
}

export default withRouter(Header)
